<template>
	<view>
		<!-- 示例1 -->
		<view>
		</view>
		<!-- 示例2：绿底白字 -->
			<!-- 割符号颜色splitorColor -->
			222222222222222
			<uni-countdown font-color="#FFFFFF" bgr-color="#000000" timer="2011-12-23 12:00:00"></uni-countdown>
		</view>
	</view>
</template>
<script>
	import uniCountdown from "../components/uni-countdown/uni-countdown.vue";
	export default {
		data() {
			// Date 对象用于处理日期和时间
			var dateObj = new Date();
			// getTime() 方法可返回距 1970 年 1 月 1 日之间的毫秒数。
			var currentTime = dateObj.getTime();
			var timer1 = this.formatDateTime((currentTime + 1000 * 2000));
			//2秒   60x60=1h  返回格式为日期或时间的表达式。formatDateTime
			var timer2 = this.formatDateTime((currentTime + 1000 * 3601));    
												
			return {
				title: '倒计时',
				timer1: timer1,
				timer2: timer2,
			}
		},
		components: {
			uniCountdown
		},
		methods: {
			formatDateTime(inputTime) { //时间戳 转 YY-mm-dd HH:ii:ss 
				var date = new Date(inputTime);
				var y = date.getFullYear();
				var m = date.getMonth() + 1;
				m = m < 10 ? ('0' + m) : m;
				var d = date.getDate();
				d = d < 10 ? ('0' + d) : d;
				var h = date.getHours();
				h = h < 10 ? ('0' + h) : h;
				var minute = date.getMinutes();
				var second = date.getSeconds();
				minute = minute < 10 ? ('0' + minute) : minute;
				second = second < 10 ? ('0' + second) : second;
				return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
			}
		},
	}
</script>

<style>
	
	
</style>